package com.acgist.polaris.entity;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import com.acgist.polaris.Tools;

/**
 * <p>负载数据</p>
 * 
 * +----------------------------+
 * |          负载数据          |
 * +----------------------------+
 * | payload.length | payload   |
 * +----------------------------+
 * | long           | byte[]    |
 * +----------------------------+
 * 
 * @author acgist
 */
public class PayloadEntity {

	/**
	 * <p>输入数据</p>
	 */
	private final InputStream input;
	/**
	 * <p>输出数据</p>
	 */
	private final OutputStream output;

	public PayloadEntity(InputStream input, OutputStream output) {
		this.input = input;
		this.output = output;
	}

	/**
	 * <p>压缩数据</p>
	 * 
	 * @throws IOException IO异常 
	 */
	public void gc() throws IOException {
		this.output.write(Tools.longToBytes(this.input.available()));
		// TODO：实现压缩
		this.input.transferTo(this.output);
	}
	
	/**
	 * <p>解压数据</p>
	 * 
	 * @throws IOException IO异常 
	 */
	public void ungc() {
	}
	
}
